

class HumanMemory:
    """ This class is used to model the human memory for the process of
    reading source code """
    
    identifierListMaxLength = 5
    checkCount = 0
    checkSuccessCount = 0
    
    def __init__(self):
        self.identifierList = []
        self.resetCheckCount()
        
    def check(self, identifier):
        self.checkCount += 1
        if identifier in self.identifierList:
            result = True
            self.checkSuccessCount += 1
        else:
            result = False
        return result
        
    def insert(self, identifier):
        if len(self.identifierList) >= self.identifierListMaxLength:
            self.identifierList.pop()
        self.identifierList.insert(0, identifier)
        
    def reset(self):
        self.identifierList = []
            
    def resetCheckCount(self):
        checkCount = 0
        checkSuccessCount = 0
        
    def printCheckInfo(self):
        if self.checkCount > 0:
            checkSuccessRate = self.checkSuccessCount / self.checkCount
            print('Human memory check success rate = ' + format(checkSuccessRate, '.2f') + ' %')
        else:
            print('Human memory check success rate = N/A')